package gui;


import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class DefaultFieldProvider implements FieldProvider {


    Map<String, Field> all = new HashMap<String, Field>();
    Set<EnumableField> enumableFields = new HashSet<EnumableField>();
    Set<Field> textFields = new HashSet<Field>();
    Set<Field> rangeFields = new HashSet<Field>();

    public DefaultFieldProvider() {


        EnumableField sex = new DefaultEnumableField("sex", "Пол");
        sex.addChoice("Мужской", "2");
        sex.addChoice("Женский", "1");
        sex.addChoice("Неизвестно", "0");
        enumableFields.add(sex);
        all.put("sex", sex);

        DefaultTextField first_name = new DefaultTextField("first_name", "Имя");
        DefaultTextField last_name = new DefaultTextField("last_name", "Фамилия");

        textFields.add(first_name);
        textFields.add(last_name);

        all.put("first_name", first_name);
        all.put("last_name", last_name);

        Field graduation_year = new DefaultRangeField("graduation_year", "Год выпуска");
        rangeFields.add(graduation_year);
        all.put(graduation_year.getFieldName(), graduation_year);

    }

    public Set<Field> getTextFields() {
        return textFields;
    }

    public Set<Field> getRangeFields() {
        return rangeFields;
    }

    public Set<EnumableField> getEnumableFields() {
        return enumableFields;
    }

    public Type getTypeByField(String field) {
        if (all.get(field) == null) {
            return Type.TEXT;
        }
        return all.get(field).getType();
    }

    public Field getFieldByName(String field) {
        return all.get(field);
    }


    public Set<String> getViewableFields() {
        Set<String> fields = new HashSet<String>();
        fields.add("first_name");
        fields.add("last_name");
        return fields;
    }

}
